package mysql

import "gorm.io/gorm"

type User struct {
	gorm.Model
	WorkNumber string `gorm:"type:varchar(50)"`
	Password   string `gorm:"type:varchar(50)"`
}

func (u *User) LoginUser(db *gorm.DB, number string) error {
	return db.Where("work_number=?", number).Find(u).Error
}

type Goods struct {
	gorm.Model
	Name   string `gorm:"type:varchar(50)"`
	Size   string `gorm:"type:varchar(50)"`
	Form   string `gorm:"type:varchar(50)"`
	Eat    string `gorm:"type:varchar(50)"`
	Use    string `gorm:"type:varchar(50)"`
	Moment string `gorm:"type:varchar(50)"`
}

func (g *Goods) AddGoods(db *gorm.DB) error {
	return db.Debug().Create(g).Error
}

func (g *Goods) UpdateGoods(db *gorm.DB, id int64) error {
	return db.Debug().Where("id=?", id).Updates(g).Error
}
